<template>
  <div class="subject-container">
    <h1>{{ categoryName }}教师列表</h1>

    <div class="teacher-list">
      <div v-for="teacher in teacherList"
           :key="teacher.userId"
           class="teacher-card"
           @click="viewTeacherDetail(teacher.teacherId)">
        <div class="teacher-avatar">
          <img :src="teacher.avatar" :alt="teacher.teacherName">
          <div class="status-tag" :class="{ 'approved': teacher.status === 'approved' }">
            {{ teacher.status === 'approved' ? '已认证' : '未认证' }}
          </div>
        </div>

        <div class="teacher-info">
          <div class="teacher-header">
            <h3>{{ teacher.teacherName }}
              <span class="gender">{{ teacher.gender === '男' ? '♂' : '♀' }}</span>
            </h3>
            <div class="price">¥{{ teacher.hourlyRate }}/小时</div>
          </div>

          <div class="tags">
            <span class="tag">{{ teacher.education }}</span>
            <span class="tag">{{ teacher.school }}</span>
            <span class="tag">{{ teacher.major }}</span>
          </div>

          <div class="certification">
            <i class="el-icon-medal-1"></i>
            {{ teacher.certification }}
          </div>

          <div class="introduction">{{ teacher.introduction }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getTeacherListByCategoryId } from "@/api/profile/profile";

export default {
  name: 'SubjectDetail',
  data() {
    return {
      categoryId: '',
      categoryName: '',
      teacherList: []
    }
  },
  created() {
    this.categoryId = this.$route.query.id
    this.categoryName = this.$route.query.name
    this.getTeacherListByCategoryId()
  },
  methods: {
    getTeacherListByCategoryId() {
      getTeacherListByCategoryId(this.categoryId).then(response => {
        this.teacherList = response
      })
    },
    viewTeacherDetail(teacherId) {
      this.$router.push({
        path: '/teacherDetail',
        query: { id: teacherId }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.subject-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px;
  min-height: 100vh;
  background: linear-gradient(135deg, #f6f8fc 0%, #f1f4f9 100%);

  h1 {
    color: #2c3e50;
    margin-bottom: 35px;
    font-size: 28px;
    font-weight: 600;
    position: relative;
    padding-left: 15px;
    border-left: 4px solid #e61e1e;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
  }
}

.teacher-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 25px;
  padding: 10px;
}

.teacher-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #e61e1e, #ff6b6b);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  &:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);

    &::before {
      opacity: 1;
    }

    .teacher-avatar img {
      transform: scale(1.05);
    }
  }

  .teacher-avatar {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;

    img {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      object-fit: cover;
      border: 3px solid rgba(230, 30, 30, 0.1);
      transition: all 0.3s ease;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .status-tag {
      position: absolute;
      bottom: 5px;
      right: 50%;
      transform: translateX(50%);
      background: rgba(144, 147, 153, 0.9);
      color: white;
      padding: 4px 12px;
      border-radius: 20px;
      font-size: 12px;
      font-weight: 500;
      backdrop-filter: blur(4px);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      transition: all 0.3s ease;

      &.approved {
        background: rgba(103, 194, 58, 0.9);
      }
    }
  }

  .teacher-info {
    .teacher-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
      padding-bottom: 15px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.05);

      h3 {
        margin: 0;
        font-size: 20px;
        font-weight: 600;
        color: #2c3e50;
        display: flex;
        align-items: center;
        gap: 8px;

        .gender {
          color: #409EFF;
          font-size: 16px;
          background: rgba(64, 158, 255, 0.1);
          padding: 2px 8px;
          border-radius: 12px;
        }
      }

      .price {
        color: #e61e1e;
        font-weight: 600;
        font-size: 18px;
        background: rgba(230, 30, 30, 0.1);
        padding: 4px 12px;
        border-radius: 20px;
      }
    }

    .tags {
      margin-bottom: 15px;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;

      .tag {
        display: inline-block;
        background: rgba(244, 244, 245, 0.8);
        color: #606266;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 13px;
        transition: all 0.3s ease;
        border: 1px solid rgba(0, 0, 0, 0.05);

        &:hover {
          background: rgba(230, 30, 30, 0.1);
          color: #e61e1e;
          transform: translateY(-2px);
        }
      }
    }

    .certification {
      color: #E6A23C;
      font-size: 14px;
      margin-bottom: 15px;
      display: flex;
      align-items: center;
      background: rgba(230, 162, 60, 0.1);
      padding: 8px 12px;
      border-radius: 12px;
      width: fit-content;

      i {
        margin-right: 8px;
        font-size: 16px;
      }
    }

    .introduction {
      color: #606266;
      font-size: 14px;
      line-height: 1.6;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      padding: 12px;
      background: rgba(0, 0, 0, 0.02);
      border-radius: 12px;
      transition: all 0.3s ease;

      &:hover {
        background: rgba(0, 0, 0, 0.04);
      }
    }
  }
}

// 添加响应式布局
@media screen and (max-width: 768px) {
  .subject-container {
    padding: 20px;
    
    h1 {
      font-size: 24px;
    }
  }

  .teacher-list {
    grid-template-columns: 1fr;
  }

  .teacher-card {
    padding: 20px;
  }
}
</style>
